$(document).ready(function() {
	var person = {
		"name" : "张三",
		"age" : 20,
		"wife" : null
	};
	/*
	 * 普通编程 $("#msg").append("姓名：" + person.name + "<br>");
	 * $("#msg").append("年龄：" + person.age + "<br>"); $("#msg").append("配偶：" +
	 * person.wife + "<br>");
	 */
	// 链式编程 减少脚本在运行的时候查找#msg的次数
	$("#msg").append("姓名：" + person.name + "<br>").append("年龄：" + person.age
			+ "<br>").append("配偶：" + person.wife + "<br>");
			
	var ary = ["中","美","俄"];
	for (var index = 0; index < ary.length; index++) {
		$("#msg2").append(ary[index]+" ");
	}
	
	var users = [{"id":1,"username":"admin","password":"123"},
					{"id":1,"username":"json","password":"123"},
					{"id":1,"username":"java","password":"123"}];
	$("#msg3").append("<table>");
	for (var i = 0; i < users.length; i++) {
		$("#msg3").append("<tr>");
		$("#msg3").append("<td>"+users[i].id+"</td>");
		$("#msg3").append("<td>"+users[i].username+"</td>");
		$("#msg3").append("<td>"+users[i].password+"</td>");
		$("#msg3").append("</tr>");
	}
	$("#msg3").append("</table>");
	
	$("#btn").click(function(){
//		alert(JSON.stringify(person));
		var str = '{"name":"admin"}';
		var obj = JSON.parse(str);
		alert(obj.name);
	});
});